package cn.com.dhcc.ddi.datasource.vo;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import cn.com.dhcc.app.core.annotation.SiColumn;
import cn.com.dhcc.app.core.annotation.SiNotDbColumn;
import cn.com.dhcc.app.core.annotation.SiTable;
import cn.com.dhcc.app.core.base.ModuleFeatureBean;

@SiTable(name = "t_ddi_table_info")
public class TableInfoVo extends ModuleFeatureBean implements Cloneable{
	@SiColumn(isId = true)
	private String id;
	@SiColumn(name = "ds_id")
	private String dsId;//数据源id
	@SiColumn(name = "schema_name")
	private String schema;//schema
	@SiColumn(name = "table_name")
	private String tableName;//表名
	@SiColumn(name = "table_comment")
	private String tableComment;//表描述
	@SiColumn(name = "table_order")
	private int tableOrder;
	private Date mtime;//最后修改时间
	@SiNotDbColumn
	private List<TableColVo> tableColVos;
	@SiNotDbColumn
	private Map<String,TableColVo> tabColMap;
	


	@SiNotDbColumn
	private String whereCondition;//where过滤条件
	@SiNotDbColumn
	private String tableType;//是否有增量字段 1 是 0 否

	public String getSchema() {
		return schema;
	}

	public void setSchema(String schema) {
		this.schema = schema;
	}

	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getDsId() {
		return dsId;
	}
	public void setDsId(String dsId) {
		this.dsId = dsId;
	}
	public String getTableName() {
		return tableName;
	}
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}
	public String getTableComment() {
		return tableComment;
	}
	public void setTableComment(String tableComment) {
		this.tableComment = tableComment;
	}
	public int getTableOrder() {
		return tableOrder;
	}
	public void setTableOrder(int tableOrder) {
		this.tableOrder = tableOrder;
	}
	public Date getMtime() {
		return mtime;
	}
	public void setMtime(Date mtime) {
		this.mtime = mtime;
	}
	public List<TableColVo> getTableColVos() {
		return tableColVos;
	}
	public void setTableColVos(List<TableColVo> tableColVos) {
		this.tableColVos = tableColVos;
	}
	public String getWhereCondition() {
		return whereCondition;
	}

	public void setWhereCondition(String whereCondition) {
		this.whereCondition = whereCondition;
	}

	public String getTableType() {
		return tableType;
	}

	public void setTableType(String tableType) {
		this.tableType = tableType;
	}

	public Map<String, TableColVo> getTabColMap() {
		return tabColMap;
	}

	public void setTabColMap(Map<String, TableColVo> tabColMap) {
		this.tabColMap = tabColMap;
	}
	
	@Override
	public String toString() {
		return "TableInfoVo [id=" + id + ", dsId=" + dsId + ", schema="
				+ schema + ", tableName=" + tableName + ", tableComment="
				+ tableComment + ", tableOrder=" + tableOrder + ", mtime="
				+ mtime + ", tableColVos=" + tableColVos + ", tabColMap="
				+ tabColMap + ", whereCondition=" + whereCondition
				+ ", tableType=" + tableType + "]";
	}

	/**
	 * 
	 * @Title: clone
	 * @Description: 克隆对象
	 * @param @param vo
	 * @param @return 参数
	 * @return TableInfoVo 返回类型
	 * @throws
	 */
    public TableInfoVo clone(TableInfoVo vo) { 
    	TableInfoVo o = null;  
    	if(vo == null){
    		return o;
    	}
        try {   
            o = (TableInfoVo)vo.clone();  
            Map<String,TableColVo> newColMap = new LinkedHashMap<String, TableColVo>();
            Map<String,TableColVo> colMap = vo.getTabColMap();
            for(String key:colMap.keySet()){
            	TableColVo colVo = colMap.get(key);
            	colVo = colVo.clone(colVo);
            	newColMap.put(key, colVo);
            }
            o.setTabColMap(newColMap);
        } catch (CloneNotSupportedException e) {  
            e.printStackTrace();  
        }  
        return o;  
    }  
	
}
